<template>
  <div v-show="dialogValue" class="add-page f-c">
    <BackPage title="考核规则配置" show-back @back="onPageBack" />
    <div class="add-form-box f-g">
      <el-form ref="formRef" :model="ruleForm" :rules="rules" class="user-add-form" inline label-position="top">
        <TitleBox title="按代办协议约定的时间内领取施工许可证的" style="margin-bottom: 40px;" />
        <el-form-item label="每个重点代办项目加">
          <div class="f-r a-c">
            <el-input clearable v-model="ruleForm.stressProjectCompletion" /> 分
          </div>
        </el-form-item>
        <el-form-item label="每个一般代办项目加">
          <div class="f-r a-c">
            <el-input clearable v-model="ruleForm.usualProjectCompletion" /> 分
          </div>
        </el-form-item>

        <TitleBox title="按代办协议约定的时间提前10天以上领取施工许可证的" style="margin-bottom: 40px;" />
        <el-form-item label="每个重点代办项目加">
          <div class="f-r a-c">
            <el-input clearable v-model="ruleForm.stressProjectReceive" /> 分
          </div>
        </el-form-item>
        <el-form-item label="每个一般代办项目加">
          <div class="f-r a-c">
            <el-input clearable v-model="ruleForm.usualProjectReceive" /> 分
          </div>
        </el-form-item>

        <TitleBox title="按代办协议约定的时间完成项目竣工验收的" style="margin-bottom: 40px;" />
        <el-form-item label="每个重点代办项目加">
          <div class="f-r a-c">
            <el-input clearable v-model="ruleForm.stressProjectEarlyReceive" /> 分
          </div>
        </el-form-item>
        <el-form-item label="每个一般代办项目加">
          <div class="f-r a-c">
            <el-input clearable v-model="ruleForm.usualProjectEarlyReceive" /> 分
          </div>
        </el-form-item>
      </el-form>
      <el-button type="primary" @click="onSave">保存</el-button>
    </div>
  </div>
</template>

<script>
import { http_performance } from '@/api'

export default {
  name: 'Config',
  data() {
    return {
      dialogValue: false,
      ruleForm: {

      },
      rules: {}
    }
  },
  methods: {
    open() {
      http_performance.readRules().then(res => {
        this.ruleForm = res.data
      })
      this.dialogValue = true
    },
    onPageBack() {
      this.dialogValue = false
    },
    onSave() {
      this.$refs.formRef.validate(valid => {
        if (valid) {
          http_performance.updateRules({ ...this.ruleForm }).then(res => {
            this.$message.success(res.msg)
            this.onPageBack()
          })
        }
      })
    }
  }
}
</script>

<style scoped lang="scss">
.add-page {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 9;
  background-color: #F6F6F6;
}
.add-form-box {
  width: 100%;
  background: #FFFFFF;
  border: 1px solid rgba(185, 185, 185, .3);
  border-radius: 16px;
  padding: 60px;
  .el-input {
    margin-right: 15px;
  }
}
</style>
